/**
 * @param {string} colors
 * @return {boolean}
 */
 var winnerOfGame = function(colors) {
  const alice = [], bob = []
  for(let i = 0, j = 1; j<colors.length; j++){
    while(colors[j] === colors[i]) j++
    if(colors[i] === 'A'){
      alice.push(j-i)
    }else{
      bob.push(j-i)
    }
    i = j
  }
  let a = 0, b = 0
  for(const x of alice){
    if(x >= 3) a += x-2
  }
  for(const y of bob){
    if(y >= 3) b += y-2
  }
  return a > b
};